﻿@model PagedResult<order_dto>
@{
    string site_img = ViewBag.img_url;
    long curUserId = ViewBag.CurUserId;
}
@{
    if (Model.rows.Count > 0) {
        foreach (var row in Model.rows) {
            <div class="item itemMana">
                <a href="/MyOrder/SellerOrderDetail?order_id=@row.id">
                    <div class="fn28">
                        <span class="col-gray">订单号：@row.order_no</span>

                        @if (row.status == OrderStatus.WaitPay) {
                            <span class="fn-right col-blue fn-bold">待支付</span>
                        } else if (row.status == OrderStatus.WaitDelivery) {
                            <span class="fn-right col-red fn-bold">待发货</span>
                        } else if (row.status == OrderStatus.Confirm) {
                            <span class="fn-right col-green fn-bold">待收货</span>
                        } else if (row.status == OrderStatus.Finish) {
                            <span class="fn-right col-gray">已完成</span>
                        } else if (row.status == OrderStatus.Close || row.status == OrderStatus.None) {
                            <span class="fn-right col-gray">已关闭</span>
                        }
                    </div>
                    <div class="fn28 mb10"><span class="col-gray">订单时间：@row.order_time.ToString("yyyy-MM-dd")</span></div>
                    @foreach (var item in row.order_items) {
                        <div class="content">
                            <div class="img">
                                @if (item.order_item_type != 6) {
                                    <img src="@(item.product.main_image_url != null ? item.product.main_image_url : site_img + item.product.first_image)" />
                                } else {
                                    <img src="@(site_img +item.bazaar_product.main_img)" />
                                }
                            </div>
                            <div class="text">
                                <div class="tit fn26">
                                    @if (item.order_item_type != 6) {@item.product.name} else {@item.bazaar_product.product_name}
                                </div>
                                <div class="price">
                                    @if (item.unit_price > 0) {
                                        <em class="fn22">￥</em><span class="fn28">@item.unit_price.ToString("0.##")</span>
                                    }
                                    @if (item.unit_price > 0 && item.red_drill > 0) {
                                        <span>+</span>
                                    }
                                    @if (item.red_drill > 0) {
                                        <span class="fn28">@item.red_drill.ToString("0.######")</span> <em class="fn22">红钻</em>
                                    }
                                    <span class="fn-right quantity">
                                        <em class="col-gray">×</em> <em class="fn28">@item.quantity </em>
                                    </span>
                                </div>
                            </div>
                        </div>
                    }
                    <div class="fn28 text-right mb10">
                        @*<span class="col-gray fn24">@row.order_time.ToString("yyyy-MM-dd")</span>*@
                        <span>
                            <em>共@(row.order_items.Sum(o => o.quantity))件商品</em>&nbsp;
                            <em>实付款：</em>
                            @if (row.pay_amount > 0) {
                                <em class="fn22">￥</em><em class="fn30">@row.pay_amount.ToString("0.##")</em>
                            }
                            @if (row.pay_amount > 0 && row.red_drill > 0) {
                                <span>+</span>
                            }
                            @if (row.red_drill > 0) {
                                <em class="fn30">@row.red_drill.ToString("0.######")</em> <em class="fn22">红钻</em>
                            }
                        </span>
                    </div>
                    <div class="btnBox">
                        @if (row.status == OrderStatus.Confirm) {
                            <a class="ui-btn ui-btn-border ui-btn-180" href="/MyOrder/OrderLogistics?order_id=@row.id">查看物流</a>
                        }
                        @if (row.status == OrderStatus.WaitDelivery && row.merchant_id == curUserId) {
                            <a class="ui-btn ui-btn-border ui-btn-180" href="/MyOrder/SellerDelivery?order_id=@row.id">发货</a>
                        }
                    </div>
                </a>
            </div>

        }
    }

    <page rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}
